Logger = class("Logger")

Logger.print = false

---

function Logger:initialize()

	gLogger = self
	
	self.history = {}
	self.currentGroup = self.history
	self.groupStack = {}
end

---

function Logger:enterGroup(name, collapsedViewByDefault)

	local newGroup = {}
	self:log(newGroup)
	
	self.groupStack[#(self.groupStack) + 1] = self.currentGroup
	self.currentGroup = newGroup
	self:log(name, false, collapsedViewByDefault)
end

---

function Logger:leaveGroup()

	self.currentGroup = self.groupStack[#self.groupStack]
	self.groupStack[#self.groupStack] = nil
end

---

function Logger:log(entry, bold, collapsedViewByDefault)

	self.currentGroup[#(self.currentGroup) + 1] = 
	{
		entry = entry,
		collapsedViewByDefault = collapsedViewByDefault,
		bold = bold
	}
	
	if Logger.print then
	
		local tabs = ""
		local hierarchyLevel = #(self.groupStack)
	
		if #self.currentGroup == 1
		then
			hierarchyLevel = hierarchyLevel - 1
		end
		
		for i = 1, hierarchyLevel  do
		
			tabs = tabs .. "\t"
		end
		
		if type(entry) ~= "table"
		then
			print(tabs .. tostring(entry))
		end
	end
end